import { defineStore } from 'pinia';
import { getMenuListApi } from "../../api/system/menu/menu.ts";

export const useMenuStore = defineStore('menuState',{
    state: () => ({
        register: false,// 路由是否注册
        routes: [], // 路由数据
    }),
    getters: {},
    actions: {
        // 生成路由
        async generateRouter() {
            const { data } = await getMenuListApi();
            console.log("data:", data);
            this.routes = data.result;  // 现在能正确访问state
            return data.result;
        }
    },
    persist: true
});

